﻿using System;
using System.Collections.Generic;
using System.Text;
using ZuDoKu.Controls;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace ZuDoKu.Screens
{
    class MainMenu : Screen
    {
        const int ButtonWidth = 75;
        const int ButtonHeight = 35;

        RadialMenuItem social, settings, cont, newGame, easy, medium, hard;
        Label debug;

        public MainMenu()
        {
            Texture2D button = Game.Content.Load<Texture2D>(@"Screens\MainMenu\button");
            Point center = new Point(Width / 2, Height / 2);

            RadialMenu menu = new RadialMenu();
            menu.X = center.X;
            menu.Y = center.Y;
            menu.Radius = 35;

            social = new RadialMenuItem(button);
            social.Pressed += new EventHandler(social_Pressed);
            social.Text = "social";
            social.Width = ButtonWidth;
            social.Height = ButtonHeight;

            settings = new RadialMenuItem(button);
            settings.Pressed += new EventHandler(settings_Pressed);
            settings.Text = "settings";
            settings.Width = ButtonWidth;
            settings.Height = ButtonHeight;

            cont = new RadialMenuItem(button);
            cont.Pressed += new EventHandler(cont_Pressed);
            cont.Text = "continue";
            cont.Width = ButtonWidth;
            cont.Height = ButtonHeight;

            newGame = new RadialMenuItem(button);
            newGame.Pressed += new EventHandler(newGame_Pressed);
            newGame.Text = "new game";
            newGame.Width = ButtonWidth;
            newGame.Height = ButtonHeight;

            easy = new RadialMenuItem(button);
            easy.Text = "easy";
            easy.Width = ButtonWidth;
            easy.Height = ButtonHeight;

            medium = new RadialMenuItem(button);
            medium.Text = "medium";
            medium.Width = ButtonWidth;
            medium.Height = ButtonHeight;

            hard = new RadialMenuItem(button);
            hard.Text = "hard";
            hard.Width = ButtonWidth;
            hard.Height = ButtonHeight;

            newGame.Add(easy);
            newGame.Add(medium);
            newGame.Add(hard);

            debug = new Label();
            debug.X = 0;
            debug.Y = Height - 25;

            Controls.Add(menu);
            Focused = menu;
            menu.Add(newGame);
            menu.Add(social);
            menu.Add(cont);
            menu.Add(settings);

            Controls.Add(debug);
        }

        void newGame_Pressed(object sender, EventArgs e)
        {
            debug.Text = "new game pressed " + DateTime.Now.ToString("hh:mm:ss:ff");
        }

        void cont_Pressed(object sender, EventArgs e)
        {
            debug.Text = "continue pressed " + DateTime.Now.ToString("hh:mm:ss:ff");
        }

        void settings_Pressed(object sender, EventArgs e)
        {
            debug.Text = "settings pressed " + DateTime.Now.ToString("hh:mm:ss:ff");
        }

        void social_Pressed(object sender, EventArgs e)
        {
            debug.Text = "social pressed " + DateTime.Now.ToString("hh:mm:ss:ff");
        }

        protected override void ProcessInput(GamePadState state)
        {
            if (state.IsButtonDown(Buttons.Back))
                OnChange(null);
                        
            base.ProcessInput(state);
        }
    }
}
